package com.xiliu.server.modules.website.controller;

import com.xiliu.common.controller.BaseController;
import com.xiliu.common.enums.BusinessType;
import com.xiliu.common.result.R;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.xiliu.common.annotation.Log;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xiliu.server.modules.website.entity.XlSlideItem;
import com.xiliu.server.modules.website.service.IXlSlideItemService;
import com.xiliu.common.page.TableDataInfo;


/**
 * 幻灯片子项表Controller
 * 
 * @author xiliu
 * @date 2022-12-05
 */
@RestController
@RequestMapping("/slide/item")
public class XlSlideItemController extends BaseController {
    @Autowired
    private IXlSlideItemService xlSlideItemService;

    /**
     * 查询幻灯片子项表列表
     */
    @PreAuthorize("@customSs.hasPermi('website:slide:list')")
    @GetMapping("/list")
    public TableDataInfo list(XlSlideItem xlSlideItem) {
        startPage();
        List<XlSlideItem> list = xlSlideItemService.selectXlSlideItemList(xlSlideItem);
        return getDataTable(list);
    }

    /**
     * 获取幻灯片子项表详细信息
     */
    @PreAuthorize("@customSs.hasPermi('website:slide:query')")
    @GetMapping(value = "/{slideItemId}")
    public R getInfo(@PathVariable("slideItemId") String slideItemId) {
        return R.ok(xlSlideItemService.selectXlSlideItemBySlideItemId(slideItemId));
    }

    /**
     * 新增幻灯片子项表
     */
    @PreAuthorize("@customSs.hasPermi('website:slide:create')")
    @Log(title = "幻灯片子项表", businessType = BusinessType.INSERT)
    @PostMapping("/create")
    public R create(@RequestBody XlSlideItem xlSlideItem) {
        boolean success = xlSlideItemService.create(xlSlideItem);
        if (success) {
            return R.ok();
        }
        return R.error("添加失败");
    }

    /**
     * 修改幻灯片子项表
     */
    @PreAuthorize("@customSs.hasPermi('website:slide:edit')")
    @Log(title = "幻灯片子项表", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/update/{slideItemId}")
    public R update(@PathVariable Long slideItemId,  @RequestBody XlSlideItem xlSlideItem) {
        xlSlideItem.setSlideItemId(slideItemId);
        boolean success = xlSlideItemService.update(xlSlideItem);
        if (success) {
            return R.ok();
        }
        return R.error("修改失败");
    }

    /**
     * 删除幻灯片子项表
     */
    @PreAuthorize("@customSs.hasPermi('website:slide:remove')")
    @Log(title = "幻灯片子项表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{slideItemIds}")
    public R remove(@PathVariable String[] slideItemIds) {
        return R.ok(xlSlideItemService.deleteXlSlideItemBySlideItemIds(slideItemIds));
    }
}
